var cmd=process.platform=='win32'?'netstat -ano':'ps aux';
var exec = require('child_process').exec;
var qqname='qq';
var port='3000';
 exec('kill pid 3000',(err,stdout,stderr) => {
    console.log(err,'err');
 });
return

exec(cmd, function(err, stdout, stderr) {
    console.log('1111',err,stdout);
    if(err){ return console.log(err); }
    
    
    stdout.split('').filter(function(line){        
        var p=line.trim().split(/s+/); 
        var address=p[1];        

        if(address!=undefined){        
            if(address.split(':')[1]==port)
            {                
                exec('taskkill /F /pid '+p[4],function(err, stdout, stderr){
                    if(err){
                        return console.log('释放指定端口失败！！');    
                    }
                    
                    console.log('占用指定端口的程序被成功杀掉！');
                });
            }
        }                          
    });
});